package j08string;

public class J3 {
    public static void main(String[] args) {
        String s1 = "aBc";
        String s2 = new String("abc");

        System.out.println(s1 == s2);//false
        System.out.println(s1.equals(s2));//true,false
        System.out.println(s1.equalsIgnoreCase(s2));//true

        String s3 = "abcxaaa";
        System.out.println(s3.length());//4
        System.out.println(s3.charAt(3));//x

        //abc  < axeee
        System.out.println("======");
        String str1 = "hello";
        String str2 = "lanou";
        String str3 = "hello lanou";
        String str4 = "hEllo";
        String str5 = "hEllo lanou";
//字符串在比较的时候，会一个字符一个字符比较。比较字符的差值，如果差值是正数，说明前的大，如果是负数说明后面的大
//如果差值是0，比较下个字符。直到比出来结果。
//this.charAt(k)-anotherString.charAt(k)
        System.out.println(str1.compareTo(str2));//负数

        System.out.println("======");
        String s100 = "aaa";
        String s200 = s100.concat("mm");
        System.out.println("s200 = " + s200);
        System.out.println("==s200===");
        String s500 = "abc";
        System.out.println(s500.contains("a"));
        System.out.println(s500.contains("c"));
        System.out.println(s500.contains("ab"));
        System.out.println(s500.contains("ac"));

        System.out.println(s500.startsWith("a"));
        System.out.println(s500.startsWith("ab"));
        System.out.println(s500.startsWith("b"));//false
    }
}
